ALLIANCE_TOP	= /opt/alliance-5.0

ENV_ASIMUT	= MBK_CATAL_NAME=CATAL_ASIMUT

ENV_COUGAR	= MBK_SPI_MODEL=$(ALLIANCE_TOP)/etc/spimodel.cfg ;\
		  export MBK_SPI_MODEL;\
		  MBK_IN_PH=ap ;\
		  export MBK_IN_PH;\
		  MBK_OUT_LO=spi;\
		  export MBK_OUT_LO


all: pipeline_inst_1.vbe check-behavioral synthesis check-synthesis place-route transistors

check-behavioral: test_pipeline_inst_1.pat result_sim.pat

synthesis: pipeline_inst_1_boom.vbe pipeline_inst_1_boog.vst pipeline_inst_1_loon.vst

check-synthesis: test_pipeline_inst_1.pat result_syn.pat

place-route: synthesis pipeline_inst_1_ocp.ap pipeline_inst_1_nero.ap pipeline_inst_1_real.cif

transistors: place-route pipeline_inst_1_transistors.spi

view-behav: result_sim.pat
	xpat -l result_sim 

view-gates: pipeline_inst_1_loon.vst
	xsch -l pipeline_inst_1_loon

view-place: synthesis pipeline_inst_1_ocp.ap
	graal -l pipeline_inst_1_ocp

view-route: synthesis pipeline_inst_1_nero.ap
	graal -l pipeline_inst_1_nero

view-real: synthesis pipeline_inst_1_real.cif
	dreal -l pipeline_inst_1_real

spice-pipeline_inst_1: pipeline_inst_1_transistors.spi
	$(ENV_COUGAR); xsch -I spi -l pipeline_inst_1_transistors

##################################################################################
##################################################################################
	
pipeline_inst_1.vbe: pipeline_inst_1.vhdl
	@echo "Conversion del archivo vhdl a vbe"
	@echo "================================="
	vasy -Vaop -I vhdl pipeline_inst_1.vhdl

test_pipeline_inst_1.pat: test_pipeline_inst_1.c
	genpat test_pipeline_inst_1

result_sim.pat: pipeline_inst_1.vbe test_pipeline_inst_1.pat
	@echo "Simulando el decodificador"
	@echo "================================="
	asimut -b pipeline_inst_1 test_pipeline_inst_1 result_sim 

pipeline_inst_1_boom.vbe: pipeline_inst_1.vbe
	@echo "Inicio de la etapa de synthesis"
	@echo "================================="
	boom pipeline_inst_1 pipeline_inst_1_boom

pipeline_inst_1_boog.vst: pipeline_inst_1_boom.vbe
	boog pipeline_inst_1_boom pipeline_inst_1_boog

pipeline_inst_1_loon.vst: pipeline_inst_1_boog.vst
	loon -o pipeline_inst_1_boog pipeline_inst_1_loon

result_syn.pat: pipeline_inst_1_loon.vst test_pipeline_inst_1.pat
	@echo "Simulando los archivos generados en la etapa de sintesis"
	@echo "========================================================"
	asimut pipeline_inst_1_loon test_pipeline_inst_1 result_syn

pipeline_inst_1_ocp.ap: pipeline_inst_1_loon.vst
	@echo "Inicio de la etapa de place and route"
	@echo "====================================="
	ocp pipeline_inst_1_loon pipeline_inst_1_ocp

pipeline_inst_1_nero.ap: pipeline_inst_1_ocp.ap pipeline_inst_1_loon.vst
	nero -p pipeline_inst_1_ocp pipeline_inst_1_loon pipeline_inst_1_nero

pipeline_inst_1_real.cif: pipeline_inst_1_nero.ap
	s2r pipeline_inst_1_nero pipeline_inst_1_real

pipeline_inst_1_transistors.spi: pipeline_inst_1_nero.ap
	$(ENV_COUGAR); cougar -t pipeline_inst_1_nero pipeline_inst_1_transistors

clean:
	rm -rf	*~ \
	*.vbe \
	*.vst \
 	*.ap \
	*.cif \
	*.xsc \
	*.pat \
	*.dat \
	*.spi \
	*#
